//
//  BaseTableViewController.swift
//  Super_WeiBo
//
//  Created by 梁超 on 16/3/15.
//  Copyright © 2016年 lc. All rights reserved.
//

import UIKit

class BaseTableViewController: UITableViewController, VisitorViewDelegate {

    /// 标记用户是否登录
    var userLogin = UserAccount.userLogine()
    
    /// 登录界面
    var visitorView : VisitorView?
    
    override func loadView() {
        userLogin ? super.loadView() : setVisitorView()
    }
    
    /**
    *  创建登录界面
    */
    private func setVisitorView ()
    {
        // 初始化未登陆界面
        let vv = VisitorView()
        view = vv
        visitorView = vv
        vv.delegate = self
        
        // 设置导航栏按钮
        navigationItem.leftBarButtonItem = UIBarButtonItem(title: "注册", style: UIBarButtonItemStyle.Plain, target: self, action: "pressRegisterWillBtn")
        navigationItem.rightBarButtonItem = UIBarButtonItem(title: "登录", style: UIBarButtonItemStyle.Plain, target: self, action: "pressLoginWillBtn")
    }
    
    //MARK: - VisitorViewDelegate
    /**
    点击登录
    */
    func pressLoginWillBtn() {
        let oauthVC = OAuthViewController()
        let oauthNav = UINavigationController(rootViewController: oauthVC)
        navigationController?.presentViewController(oauthNav, animated: true, completion: nil)
    }
    /**
     点击注册
     */
    func pressRegisterWillBtn() {
        
    }
}
